import React, { lazy } from 'react';
import { useRoutes, RouteObject } from 'react-router-dom';
import withRouter from './withRouter';
const FinanceScreen = lazy(() => import('@/pages/financeScreen/financeScreen'));
const ImgSwiper = lazy(() => import('@/pages/financeScreen/components/imgSwiper/imgSwiper'));
const CoinFountain = lazy(() => import('@/pages/financeScreen/components/coinFountain/coinFountain'));

export const routeConfig: RouteObject[] = [
    {
        path: '/',
        element: <FinanceScreen />,
    },
    {
        path: '/imgSwiper',
        element: <ImgSwiper />,
    },
    {
        path: '/coinFountain',
        element: <CoinFountain />,
    },
];

export const RenderRouters = withRouter(({ config }: { config: RouteObject[] }) => {
    const element = useRoutes(config);

    return element;
});

export default RenderRouters;
